{$layout}

<!-- 检测配置更新 -->
<proxy-change-notify-box></proxy-change-notify-box>

<div>
	{$template "/proxy/menu"}

	<p>在这里可以设置<strong>全局的WAF策略</strong>，如果你想只对某些URL进行控制，请点击"路径规则"进行设置。</p>
</div>

<p class="comment" v-if="wafList.length == 0">暂时还没有可以使用的WAF。</p>
<div v-if="wafList.length > 0" style="margin-top:1em">
	<table v-if="server.wafId.length == 0 && !formVisible" class="ui table definition selectable">
		<tr>
			<td class="title">WAF策略</td>
			<td>还没有设置WAF策略，<a href="" @click.prevent="showForm()">设置</a> </td>
		</tr>
	</table>

	<table v-if="server.wafId.length > 0 && !formVisible" class="ui table definition selectable">
		<tr>
			<td class="title">WAF策略</td>
			<td><a :href="'/proxy/waf/detail?wafId=' + waf.id">{{waf.name}}</a>
				&nbsp; <a href="" style="font-size: 0.8em;" @click.prevent="updateWAF()">[修改]</a>
			</td>
		</tr>
	</table>
</div>

<form class="ui form" style="margin-top:1em" v-show="formVisible" data-tea-action=".waf.update" data-tea-success="submitSuccess">
	<input type="hidden" name="serverId" :value="server.id"/>
	<table class="ui table definition selectable" v-if="wafList.length > 0">
		<tr>
			<td class="title">WAF策略</td>
			<td>
				<select class="ui dropdown" name="wafId" v-model="wafId" style="width:10em">
					<option value="">[不使用WAF]</option>
					<option v-for="waf in wafList" :value="waf.id">{{waf.name}}</option>
				</select>
			</td>
		</tr>
	</table>
	<button class="ui button primary" type="submit">保存</button> &nbsp;
	<a href="" @click.prevent="cancelForm()">取消</a>
</form>